package com.ibiaoke.boss.controller;

import com.ibiaoke.common.base.Page;
import com.ibiaoke.common.response.Res;
import com.ibiaoke.marketing.entity.Marketing;
import com.ibiaoke.marketing.service.MarketingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class BossMarketingController {

    @Autowired
    private MarketingService marketingService;


    @RequestMapping("/saveMarketing")
    @ResponseBody
    public Res saveMarketing(Marketing marketing) {
        marketingService.saveMarketing(marketing);
        return Res.create();
    }

    @RequestMapping("/updateMarketing")
    @ResponseBody
    public Res updateMarketing(Marketing marketing) {
        marketingService.updateMarketing(marketing);
        return Res.create();
    }

    @RequestMapping("/listMarketing")
    @ResponseBody
    public Res listMarketing(String marketingName, Page page) {
        List<Marketing> list = marketingService.listMarketing(marketingName, page);
        return Res.create().addResponse("MarketingList", list).addResponse("page",page);
    }

    @RequestMapping("/getMarketing")
    @ResponseBody
    public Res getMarketing(Integer marketingId) {
        Marketing marketing = marketingService.getMarketing(marketingId);
        return Res.create().addResponse("marketing", marketing);
    }


    @RequestMapping("/deleteMarketing")
    @ResponseBody
    public Res deleteMarketing(Integer marketingId) {
        marketingService.deleteMarketing(marketingId);
        return Res.create();
    }
}
